package com.hsy.linemoney.modules.exchange;

import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.text.SpannableString;
import android.text.SpannedString;
import android.text.style.ForegroundColorSpan;
import android.view.KeyEvent;
import android.widget.ImageButton;
import android.widget.TextView;

import com.deparse.dpframe.tools.utils.DPLogUtil;
import com.deparse.dpframe.ui.common.DPBusEvent;
import com.hsy.linemoney.R;
import com.hsy.linemoney.common.Consts;
import com.hsy.linemoney.modules.common.CommonBaseActivityWithSimpleActionBar;

/**
 * Created by Administrator on 2016/12/15.
 */

public class ExchangeFinishActivity extends CommonBaseActivityWithSimpleActionBar {
    protected TextView account;
    protected TextView accountString;

    @Override
    public boolean onActionBarLeftButtonClicked(ImageButton leftButton) {
        DPBusEvent event = new DPBusEvent();
        event.what = Consts.BusEventCommands.FINISH_EXCHANGE_STEP_2_AND_3;
        postBusEvent(event);
        finish();
        return super.onActionBarLeftButtonClicked(leftButton);
    }

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (KeyEvent.KEYCODE_BACK == keyCode) {
            DPBusEvent event1 = new DPBusEvent();
            event1.what = Consts.BusEventCommands.FINISH_EXCHANGE_STEP_2_AND_3;
            postBusEvent(event1);
            finish();
        }
        return super.onKeyUp(keyCode, event);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.setContentView(R.layout.activity_exchange_finish);
        setTitle(R.string.base_exchange_finish_title);
        initView();
        if (null != getActivityStartExtra()) {
            String s = getResources().getString(R.string.base_exchange_finish_texts);
            account.setText(String.format(s, getActivityStartExtra()[0]));
            String string = getActivityStartExtra()[1];
            DPLogUtil.d("string=" + string);
//            您的贵宾折扣是0.61 美元, 请您将59.39 美元 汇入快汇<a href="https://www.paypal.com/home" target="_blank">美国贝宝</a>账户account01.us@linemoney.com.
            accountString.setText(Html.fromHtml(string));

        }
    }

    private void initView() {
        account = (TextView) findViewById(R.id.account);
        accountString = (TextView) findViewById(R.id.account_string);
    }
}
